package com.cxy.springbootelasticjob.job;

import com.cxy.autoconfig.ElasticSimpleJob;
import com.cxy.springbootelasticjob.service.OrderService;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author: huayushu luming
 * @date: 2020-11-04 19:55
 * @desc:
 **/
@Slf4j
//@ElasticSimpleJob(jobName = "mySimpleJob",cron ="0/55 * * * * ?",shardingTotalCount = 1,overwrite = true)
public class MysimpleJob implements SimpleJob {
    @Autowired
    private OrderService orderService;
    @Override
    public void execute(ShardingContext shardingContext) {
        //模拟  插入数据
        for(int i = 0;i<10;i++) {
          orderService.insertOrder();
        }
        log.info("我是分片项："+shardingContext.getShardingItem()+"总分片数是："+shardingContext.getShardingTotalCount());
    }
}
